package com.baosight.sczx.common.zm.cInterface.cb;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.dao.Dao;
import com.baosight.sczx.common.zm.cInterface.cs.SystemSettingCP;

/**
 * 采区 对外接口
 * <p>Title: Mine.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 高强
 * @version 1.0
 * <pre>Histroy:
 *        2013-7-3 上午11:01:49  高强 
 *</pre>
 */
public class Miningarea {

	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");
	
	/**
	 * 矿井建模 中用到的采区
	 * <p>Function: getLevel</p>
	 * <p>Description: </p>
	 * <p>return value:List<Map></p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *  2013-7-3 上午11:01:49  高强 
	 * </p>
	 *
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public static List<Map> getMiningarea(Map<String, String> _argMap){
		_argMap = _argMap == null ? new HashMap<String, String>():_argMap;
		List<Map>  _list = new ArrayList();
		try {
			_list = dao.query("ZMCBMiningarea.queryTree", _argMap);
		} catch (Exception e) {
			
		}
		return _list;
	}
	
	/**
	 * <p>Function: getParnetInforWfBlock</p>
	 * <p>Description: </p>
	 * <p>return value: EiBlock</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *   2013-06-21下午15:31:29  高强
	 * </p>
	 *
	*/
	@SuppressWarnings({ "rawtypes", "unchecked"})
	public static EiBlock getParnetInforWfBlock()
	{
		EiBlock block = new EiBlock("cmes.cb.parentInforWf");

		EiColumn eiColumn = new EiColumn("display");
		eiColumn.setType("C");
		block.addMeta(eiColumn);

		eiColumn = new EiColumn("value");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		List<Map>  _list = new ArrayList<Map>();
		String value =SystemSettingCP.getInstance().getMingModel();
		if(value.equals("0") ||value.equals("1"))//采区信息
		{
			_list = dao.query("ZMCBMiningarea.queryInterface", null);
		}else //矿井信息
		{
			_list = dao.query("ZMCBMine.queryInterface", null);
		}
		
		block.setRows(_list);
		return block;
	}
	
	/**构造是否两翼开采block
	 * <p>Function: getIsWings</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCB01</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-06-21下午15:31:29  高强
	 * </p>
	 *
	*/
	@SuppressWarnings("rawtypes")
	public static EiBlock  getIsWings(String blockName)
	{
		EiBlock block = new EiBlock(blockName);

		EiColumn eiColumn = new EiColumn("value");
		eiColumn.setType("C");
		block.addMeta(eiColumn);

		eiColumn = new EiColumn("display");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		List<Map>  _list = new ArrayList<Map>();
		Map<String, String> _map = new HashMap<String, String>();
		
		_map = new HashMap<String, String>();
		_map.put("display", "否");
		_map.put("value", "否");
        _list.add(_map);
        
        _map = new HashMap<String, String>();
		_map.put("display", "南北翼");
		_map.put("value", "南北翼");
        _list.add(_map);
        
        _map = new HashMap<String, String>();
		_map.put("display", "东西翼");
		_map.put("value", "东西翼");
        _list.add(_map);
        block.setRows(_list);
		return block;
	}
	
	/**
	 * 根据水平ID获取其下的首采区ID
	 * <p>Function: getFirstMingingArea</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-9-16上午06:58:15 张志芳
	 * </p>
	 *
	 */
	public static String getFirstMingingArea(String levelId){
		String ma = "";
		Map map = new HashMap();
		map.put("fdParentId", levelId);
		map.put("fdIsFirst", "是");
		List<Map> list = dao.query("ZMCBMiningarea.queryInterface2", map);
		if(list.size()>0){
			ma = (String)list.get(0).get("fdKeyId");
		}
		return ma;
	}
}
